package o;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import com.huawei.hms.framework.common.ContainerUtils;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import java.util.ArrayList;
import java.util.List;

public class enx {
    private static final List<String> ˋ = new ArrayList();

    static {
        ˋ.add("serviceType=");
        ˋ.add("sign=");
        ˋ.add("hcrId=");
        ˋ.add("devicetype=");
        ˋ.add("clientPackage=");
        ˋ.add("thirdId=");
        ˋ.add("token=");
        ˋ.add("iv=");
        ˋ.add("terminalType=");
        ˋ.add("userId=");
    }

    public static void ˏ(Context context, String str) {
        try {
            Intent intent = new Intent(ACTION.HWID_SCHEME_URL, Uri.parse(str));
            if (!(context instanceof Activity)) {
                intent.setFlags(268435456);
            }
            context.startActivity(intent);
        } catch (Exception e) {
            Logger.e("WebViewUtil", "openSystemView error");
        }
    }

    public static String ॱ(String str) {
        if (dof.ˋ(str)) {
            return "";
        }
        int indexOf = str.indexOf("?");
        return indexOf != -1 ? str.substring(0, indexOf) : str;
    }

    public static void ॱ(Context context) {
        CookieSyncManager.createInstance(context);
        CookieManager.getInstance().removeAllCookie();
        CookieSyncManager.getInstance().sync();
    }

    public static String ˎ(String str) {
        if (TextUtils.isEmpty(str)) {
            Logger.ˎ("WebViewUtil", "uri is null.");
            return null;
        }
        try {
            CharSequence queryParameter = Uri.parse(str).getQueryParameter("shareUrl");
            Logger.ˏ("WebViewUtil", "share url param is empty ? " + TextUtils.isEmpty(queryParameter));
            return queryParameter;
        } catch (Exception e) {
            Logger.e("WebViewUtil", "parserParamUrl exception.");
            return null;
        }
    }

    public static String ˏ(String str) {
        String str2 = null;
        int i = 0;
        if (str == null) {
            return null;
        }
        String substring;
        int indexOf = str.indexOf("?");
        if (indexOf > 0) {
            substring = str.substring(0, indexOf);
            str2 = str.substring(indexOf + 1);
        } else {
            substring = str;
        }
        if (str2 == null) {
            return str;
        }
        String[] split = str2.split(ContainerUtils.FIELD_DELIMITER);
        List arrayList = new ArrayList();
        int i2 = 0;
        while (i2 < split.length) {
            if (!(split[i2] == null || split[i2].equals("") || ˊ(split[i2]))) {
                arrayList.add(split[i2]);
            }
            i2++;
        }
        StringBuilder stringBuilder = new StringBuilder(substring);
        int size = arrayList.size();
        if (size > 0) {
            stringBuilder.append("?");
            while (i < size) {
                stringBuilder.append((String) arrayList.get(i));
                if (i != size - 1) {
                    stringBuilder.append('&');
                }
                i++;
            }
        }
        return stringBuilder.toString();
    }

    private static boolean ˊ(String str) {
        for (String startsWith : ˋ) {
            if (str.startsWith(startsWith)) {
                return true;
            }
        }
        return false;
    }
}
